﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zj.OpenAuth.Domain.Core;

namespace Zj.OpenAuth.Repository.Models.Mapping
{
    /// <summary>
    /// deparment fluent api maping
    /// </summary>
    public class DepartmentMap
        : EntityTypeConfiguration<Department>
    {
        public DepartmentMap()
        {
            //table
            ToTable("Department", "dbo");



            //keys
            HasKey(t => t.Id);



            //properties
            this.Property(t => t.Id)
                .HasColumnName("Id")
                .IsRequired();

            this.Property(t => t.Text)
                .HasColumnName("Text")
                .HasMaxLength(36)
                .IsRequired();

            this.Property(t => t.Code)
                .HasColumnName("Code")
                .HasMaxLength(36)
                .IsRequired();

            this.Property(t => t.Description)
                .HasColumnName("Description")
                .HasMaxLength(1000);

            this.Property(t => t.Phone)
                .HasColumnName("Phone")
                .IsRequired();

            this.Property(t => t.Phone)
                .HasColumnName("Phone")
                .IsRequired();

            this.Property(t => t.Status)
                .HasColumnName("Status")
                .IsRequired();

            this.Property(t => t.ParentId)
                .HasColumnName("ParentId")
                .IsOptional();

            this.Property(t => t.ManagerId)
                .HasColumnName("ManagerId")
                .IsOptional();

            this.Property(t => t.CreatorId)
                .HasColumnName("CreatorId")
                .IsOptional();

            this.Property(t => t.CreateTime)
                .HasColumnName("CreateTime")
                .IsRequired();

            this.Property(t => t.LastModifierId)
                .HasColumnName("LastModifierId")
                .IsOptional();

            this.Property(t => t.LastModifyTime)
                .HasColumnName("LastModifyTime")
                .IsOptional();
        }
    }
}
